import 'package:Smart/pages/productor001/studytest/study_main_001.dart';
import 'package:Smart/pages/productor002/studytest/study_main_002.dart';
import 'package:Smart/pages/productor003/studytest/study_main_003.dart';
import 'package:Smart/pages/productor004/studytest/study_main_004.dart';
import 'package:Smart/pages/productor005/studytest/study_main_005.dart';
import 'package:Smart/pages/productor006/studytest/study_main_006.dart';
import 'package:Smart/pages/productor007/studytest/study_main_007.dart';
import 'package:Smart/pages/productor008/studytest/study_main_008.dart';
import 'package:Smart/res/colors_res.dart';
import 'package:Smart/utils/routers/page_jump_service.dart';
import 'package:Smart/utils/toast_util.dart';
import 'package:flutter/material.dart';

class CenterPage extends StatefulWidget {
  @override
  _MineState createState() => _MineState();
}

class _MineState extends State<CenterPage> {

  List listData = [
    {"title": "1.谭文玉"},
    {"title": "2.唐文煜"},
    {"title": "3.张楚"},
    {"title": "4.杨玉霜"},
    {"title": "5.王洋钊"},
    {"title": "6.字永芳"},
    {"title": "7.刘佳"},
    {"title": "8.杨情缘"},
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // elevation: 0,
        backgroundColor: ColorsRes.color_ffffff,
        title: Text(
          "个人练习",
          style: TextStyle(color: ColorsRes.color_000000),
        ),
      ),
      body: ListView.builder(
        itemCount: listData.length,
        itemBuilder: (BuildContext context, int index) {
          return listItem(listData[index]["title"], onTap: () {
            itemAction(context, index);
          });
        },
      ),
    );
  }

  // ListItem
  Widget listItem(String title, {Function onTap}) {
    return ListTile(
      contentPadding: EdgeInsets.all(0),
      title: Container(
        height: 48,
        // margin: EdgeInsets.all(0),
        // padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
        child: Center(child: Text(title)),
        color: Colors.orange,
      ),
      onTap: onTap,
    );
  }

  // Item事件相应
  void itemAction(BuildContext context, int index) {
    switch(index){
      case 0:
        PageJumpService.instance().goTo(StudyMain001(listData[index]["title"]));
        break;
      case 1:
        PageJumpService.instance().goTo(StudyMain002(listData[index]["title"]));
        break;
      case 2:
        PageJumpService.instance().goTo(StudyMain003(listData[index]["title"]));
        break;
      case 3:
        PageJumpService.instance().goTo(StudyMain004(listData[index]["title"]));
        break;
      case 4:
        PageJumpService.instance().goTo(StudyMain005(listData[index]["title"]));
        break;
      case 5:
        PageJumpService.instance().goTo(StudyMain006(listData[index]["title"]));
        break;
      case 6:
        PageJumpService.instance().goTo(StudyMain007(listData[index]["title"]));
        break;
      case 7:
        PageJumpService.instance().goTo(StudyMain008(listData[index]["title"]));
        break;
    }
  }
}
